package chen.web.util.ubb;

import java.util.HashMap;
import java.util.Map;

public class TagFactory {

	private  Map<String, UbbTag> tagMap = new HashMap<String, UbbTag>();
	
	public void register(UbbTag ... tags){
		for(UbbTag tag : tags){
			tagMap.put(tag.getName(), tag);	
		}
	}
	
	UbbTag getTagInstance(String tagName, String property){
		
		UbbTag tagInstance = tagMap.get(tagName);
		if(tagInstance == null){
			return null;
		}
		
		UbbTag tag = tagInstance.newInstance();
		tag.setProperty(property);
		return tag;	
	}
}
